package cn.tedu.micro.demo.order.controller;

import cn.tedu.micro.demo.device.common.pojo.protocol.JsonResult;
import cn.tedu.micro.demo.order.pojo.dto.OrderCommitParam;
import cn.tedu.micro.demo.order.service.OrderService;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
public class OrderController {
    @Autowired
    OrderService orderService;

    @Value("${server.port}")
    private String port;
    @PostMapping("/order/create")
    public JsonResult<String> createOrder(OrderCommitParam orderCommitParam){
        log.info("订单提交参数：{}",orderCommitParam);
        String uuid = orderService.createOrder(orderCommitParam);
        return JsonResult.ok("订单提交成功",uuid);
    }
    @GetMapping("/order/hello")
    public String hello(){
        return "hello i am from " + port;
    }
}
